@extends('admin.public')

@section('content')
    @if((bool)\Auth::guard('admin')->user()->is_root)
        <div class="col-md-12">
            <section class="panel panel-default text-sm doc-buttons">
                <div class="panel-body">
                    <a href="{{ route('admin.index.area_add') }}" class="btn btn-info"><i class="icon-plus ico"></i>
                        &nbsp; 添加地区</a>
                    <button id="nestable-menu" class="btn btn-success" data-toggle="button">
                        <i class="fa fa-plus text fa-fw"></i>
                        <span class="text">收起</span>
                        <i class="fa fa-minus text-active fa-fw"></i>
                        <span class="text-active">展开</span>
                    </button>
                </div>
            </section>
        </div>
    @endif

    <div class="col-md-12">
        <div class="dd" id="nestable3">
            <ol class="dd-list">
                @if(!empty($area))
                    @foreach($area as $arealv1)
                        <li class="dd-item dd3-item" data-id="13">
                            <div class="dd-handle dd3-handle">Drag</div>
                            <div class="dd3-content">
                                <a class="text-info"
                                   href="{{ route('index_area',$arealv1['domain']) }}">{{ $arealv1['name'] }}</a>
                                @if(empty($arealv1['children']))
                                    <a href="{{ route('admin.index.area') }}?del={{ $arealv1['id'] }}"
                                       class="btn btn-xs btn-danger pull-right m-l">删除</a>
                                @endif
                                <a href="{{ route('admin.index.area_edit',$arealv1['id']) }}"
                                   class="btn btn-xs btn-default pull-right">编辑</a>
                            </div>
                            <ol class="dd-list">
                                @if(!empty($arealv1['children']))
                                    @foreach($arealv1['children'] as $arealv2)
                                        <li class="dd-item dd3-item" data-id="13">
                                            <div class="dd3-content">
                                                <a class="text-info" target="_blank"
                                                   href="{{ route('index') }}?area={{ $arealv2['domain'] }}">{{ $arealv2['name'] }}</a>
                                                @if(empty($arealv2['children']))
                                                    <a href="{{ route('admin.index.area') }}?del={{ $arealv2['id'] }}"
                                                       class="btn btn-xs btn-danger pull-right m-l">删除</a>
                                                @endif
                                                <a href="{{ route('admin.index.area_edit',$arealv2['id']) }}"
                                                   class="btn btn-xs btn-default pull-right">编辑</a>
                                            </div>
                                            <ol class="dd-list">
                                                @if(!empty($arealv2['children']))
                                                    @foreach($arealv2['children'] as $arealv3)
                                                        <li class="dd-item dd3-item" data-id="13">
                                                            <div class="dd3-content">
                                                                <a class="text-info" target="_blank"
                                                                   href="{{ route('index') }}?area={{ $arealv3['domain'] }}">{{ $arealv3['name'] }}</a>
                                                                @if(empty($arealv3['children']))
                                                                    <a href="{{ route('admin.index.area') }}?del={{ $arealv3['id'] }}"
                                                                       class="btn btn-xs btn-danger pull-right m-l">删除</a>
                                                                @endif
                                                                <a href="{{ route('admin.index.area_edit',$arealv3['id']) }}"
                                                                   class="btn btn-xs btn-default pull-right">编辑</a>
                                                            </div>
                                                            <ol class="dd-list">
                                                                @if(!empty($arealv3['children']))
                                                                    @foreach($arealv3['children'] as $arealv4)
                                                                        <li class="dd-item dd3-item" data-id="13">
                                                                            <div class="dd3-content">
                                                                                <a class="text-info" target="_blank"
                                                                                   href="{{ route('index') }}?area={{ $arealv4['domain'] }}">{{ $arealv4['name'] }}</a>
                                                                                @if(empty($arealv4['children']))
                                                                                    <a href="{{ route('admin.index.area') }}?del={{ $arealv4['id'] }}"
                                                                                       class="btn btn-xs btn-danger pull-right m-l">删除</a>
                                                                                @endif
                                                                                <a href="{{ route('admin.index.area_edit',$arealv4['id']) }}"
                                                                                   class="btn btn-xs btn-default pull-right">编辑</a>
                                                                            </div>
                                                                        </li>
                                                                    @endforeach
                                                                @endif
                                                            </ol>
                                                        </li>
                                                    @endforeach
                                                @endif
                                            </ol>
                                        </li>
                                    @endforeach
                                @endif
                            </ol>
                        </li>
                    @endforeach
                @endif
            </ol>
        </div>
    </div>


@endsection

@section('css')
    <link rel="stylesheet" href="/public/theme/js/nestable/nestable.css" type="text/css"/>
@endsection

@section('js')
    <script src="/public/theme/js/sortable/jquery.sortable.js"></script>
    <script src="/public/theme/js/nestable/jquery.nestable.js"></script>
    <script src="/public/theme/js/nestable/demo.js"></script>
    <script>
        $(function () {
            $('#nestable-menu').click();
        })
    </script>
@endsection
